package sistemioperativi.matrice.es2;

public class ScannerColonne extends Thread{
		
		private int [][]matrix;
		private int colonnaAssegnata;
		private int cordRiga = -1;
		
		
	public ScannerColonne (int [][] matrix, int colonnaAssegnata){
		
		this.matrix = matrix;
		this.colonnaAssegnata = colonnaAssegnata;
	
	}
	
	
	public boolean ready(){
		if(this.getRiga() != -1)
			return true;
		return false;
	}
	
	public int getRiga(){
		try{
			
		join();
		return this.cordRiga;
	}catch(Exception e){};
	
	return -1;
	}
	
	public int[] getCordMinColonne(){

		
		try{
			
		join();
		int[] a = new int[2];
		a[0] = this.cordRiga;
		a[1] = this.colonnaAssegnata;
	
		return a;
	}catch(Exception e){};
	
		return null;
	}
	
	public void run(){
		
		//cerco il minimo della colonna
		
		int min = Integer.MAX_VALUE;
		
		for(int i = 0; i<matrix.length; i++){
			if(matrix[i][colonnaAssegnata] < min){
				min = matrix[i][colonnaAssegnata];
				this.cordRiga = i;
			}
		}
	}

}
